package cn.remex.task.model;

import cn.remex.core.quartz.Task.TriggerType;
import cn.remex.db.rsql.model.ModelableImpl;
import cn.remex.task.TaskConst.ProcessStatus;

import javax.persistence.Column;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import java.util.Date;

import static cn.remex.core.quartz.Task.TriggerType.once;


/**
 * @author liuhengyang
 * date 2016-12-23 下午6:22:25
 * @version 版本号码
 */
@Table(
		uniqueConstraints = @UniqueConstraint(columnNames = {"sysTask", "matterType"})
)
public class SysMatter extends ModelableImpl {
	//用于唯一标示配置及分析器的key
	public String key(){
		return getSysTask().getTaskType() + "_" + getSysTask().getRelationId();
	}

	// 分析器
	@ManyToOne
	private SysTask sysTask;
	private String matterType;//信审工作的类型
	private TriggerType triggerType = once;//调度类型
	private String cron = "0/10 * * * * ?";//调度时间 默认每10秒调用一次，0秒开始
	private Date planStartTime;//计划启动时间
	private ProcessStatus processStatus;//信审工作状态
	private int allowFailTimes=1;
	public Date startTime;
	public Date endTime;

	@Column(length = 4096)
	private String params;//具体信审任务的参数
	@Column(length = 4096)
	private String results;//任务结果


	public int getAllowFailTimes() {
		return allowFailTimes;
	}

	public void setAllowFailTimes(int allowFailTimes) {
		this.allowFailTimes = allowFailTimes;
	}

	public String getCron() {
		return cron;
	}

	public void setCron(String cron) {
		this.cron = cron;
	}

	public TriggerType getTriggerType() {
		return triggerType;
	}

	public void setTriggerType(TriggerType triggerType) {
		this.triggerType = triggerType;
	}

	public Date getPlanStartTime() {
		return planStartTime;
	}

	public void setPlanStartTime(Date planStartTime) {
		this.planStartTime = planStartTime;
	}

	public String getResults() {
		return results;
	}

	public void setResults(String results) {
		this.results = results;
	}

	public String getParams() {
		return params;
	}

	public void setParams(String params) {
		this.params = params;
	}

	public SysTask getSysTask() {
		return sysTask;
	}

	public void setSysTask(SysTask sysTask) {
		this.sysTask = sysTask;
	}

	public String getMatterType() {
		return matterType;
	}

	public void setMatterType(String matterType) {
		this.matterType = matterType;
	}

	public ProcessStatus getProcessStatus() {
		return processStatus;
	}

	public void setProcessStatus(ProcessStatus processStatus) {
		this.processStatus = processStatus;
	}

	public Date getStartTime() {
		return startTime;
	}

	public void setStartTime(Date startTime) {
		this.startTime = startTime;
	}

	public Date getEndTime() {
		return endTime;
	}

	public void setEndTime(Date endTime) {
		this.endTime = endTime;
	}
}
